<?php

/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/


  defined('_JEXEC') or die('Retricted Access');
  rendfield_JS();
   JFilterOutput::objectHTMLSafe( $this->item );
   JHTML::_('behavior.tooltip');
   JHTML::_('behavior.formvalidation');    
?>

<script type="text/javascript" language="javascript">
//<![CDATA[
	function submitbutton(pressbutton) {
		
	
		if(pressbutton == 'apply' || pressbutton == 'save'){
	    }
	    document.profileForm.task.value = pressbutton;
	    document.profileForm.submit();
		
	}
	function usergroup_change()
	{
		if (value=document.userdetailForm.usergroup.value)
		{
			window.location = 'index.php?option=com_jajobboard&view=jausergroup&userdetail=true&group='+value;
		}
		else
		{
			window.location = 'index.php?option=com_jajobboard';
		}
		
	}
//]]>
</script>

<?php 
	global  $option, $mainframe;
//	include_once('components/'.$option.'/views/jafrontend_view.php');
	$userdetail = JRequest::getVar('userdetail');
//	$user_view = Show_UserType_SelectBox();
	$usertype = JRequest::getVar('group');
?>

<div id="jobboard-content">
	<form name="profileForm" class="form-validate" action="<?php echo JURI::root();?>index.php?userdetail=<?php echo $userdetail ?>" method="post" enctype="multipart/form-data">
	<?php
	$user= JFactory::getUser();
	if(getCurrentUserType() == JBEMPLOYER_USER && $this->item->user_id == $user->id)
	{?>	
			<div class="moduletable profile-box">				
				<table class="tabledata profiledetails">
			            <?php
			            $k=0;
	            		
			            for($i = 0, $n = count($this->fieldlist); $i < $n; $i++ ){
							
		                	$field = $this->fieldlist[$i];
		                	
		                	if($field->display=='admin_only' && $user->aid<2) continue;
		                	
		                    if($field->field_type=='SEPERATOR' && $field->display!='hide_all'){?>	
					                
							    </table>
							    </div>
							    
							    <div class="moduletable profile-box">
									<h3>
										<?php echo JText::_($field->label);?>
								    </h3>
								    
									<table class="tabledata profiledetails">
							<?php }else{ 
				                    	$edit = $this->item->id?true:false;	
				                    	$action = (isset($this->item->id)&&($this->item->id!=0)&&($this->item->id!=null))?'edit':'new';
								        $firstIndex = findFirstField($this->item,$this->fieldlist,$action);
										$lastIndex = findLastField($this->item,$this->fieldlist,$action);
										$input = rendfield($this->item, $field, false, $edit);
				                        
			                        	if ($i==$firstIndex) 		$classname = 'first';
								      	elseif ($i==$lastIndex)		$classname = 'last';
								      	else 						$classname = 'sectiontableentry'.($k+1);
				                        
								      	if( ($action=='new' && $field->display=='hide_on_new') ||  ($field->display=='hide_all') ){?>
							           		<?php echo $input;?>
							           	<?php }else{?>				           	
								       		 <tr class="<?php echo $classname; ?>">
								                <td class="col1">
								                <?php echo JText::_($field->label); ?>:
								                </td>
								                
								                <td class="col2">
								                   <?php echo $input;?>
								                </td>
								            </tr> 
							            <?php }?>      
						                
					                	<?php $k = 1 - $k;
						       }
			            }?>			
						            
					</table>			
				</div>			
	         	<input class="button" type="button" onclick="submitbutton('save');" value="<?php echo JText::_('Save'); ?>" />
	         	<input class="button" type="button" onclick="submitbutton('cancel');" value="<?php echo JText::_('Cancel'); ?>" />      			           
	<?php
	}    
	if (!$this->item->id){
		echo '<input type="hidden" name="create_date" value="'.date("Y-m-d H:m:s").'" />';
	} ?>
	    
	<input type="hidden" name="cid[]" value="<?php echo $user->id; ?>" />

	<input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
	<input type="hidden" name="view" value="japrofiles" />
	<input type="hidden" name="task" value="save" />
	<input type="hidden" name="Itemid" value="<?php echo JRequest::getInt('Itemid', 0); ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>	
	</form>
</div>